package com.wsc.wisdomchinaqinghe.activitity.wisdomParty;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.wsc.wisdomchinaqinghe.R;
import com.wsc.wisdomchinaqinghe.Tools.JsonTools;
import com.wsc.wisdomchinaqinghe.Tools.Tools;
import com.wsc.wisdomchinaqinghe.activitity.baseactivity.BaseActivity;
import com.wsc.wisdomchinaqinghe.constant.Constant;
import com.wsc.wisdomchinaqinghe.javaBean.wisdomParty.PartyUserBean;


public class PartyUserActivity extends BaseActivity implements View.OnClickListener{
    private ImageView iv_back;
    private Context context;
    private TextView tv_guize;
    private TextView tv_name;
    private TextView tv_age;
    private Button bt_finish;
    private TextView tv_affiliated;
    private TextView tv_partyDuties;
    private TextView tv_admDuties;
    private TextView tv_joinPartyDate;
    private TextView tv_contactNumber;
    private ImageView iv_headImg;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.partyuser_layout);
        initView();
        String message=Tools.getSharedPreferencesStrings(Constant.SharePreferencePartyUserInfo,"",context);
        if(message!=null && message!="")
        {
            PartyUserBean partyUserBean= JsonTools.jsonStringToObject(message,PartyUserBean.class);
            tv_name.setText(partyUserBean.getName());
            tv_age.setText(partyUserBean.getAge()+"");
            tv_affiliated.setText(partyUserBean.getAffiliated());
            tv_partyDuties.setText(partyUserBean.getPartyDuties());
            tv_admDuties.setText(partyUserBean.getAdmDuties());
            tv_joinPartyDate.setText(Tools.formatDateTimeyyyyMMDD(Tools.formatData(partyUserBean.getJoinPartyDate())));
            tv_contactNumber.setText(partyUserBean.getContactNumber());
            Glide.with(context).load(partyUserBean.getHeadImg())
                    .diskCacheStrategy(DiskCacheStrategy.ALL)
                    .placeholder(R.mipmap.me)
                    .into((ImageView) iv_headImg);
        }
    }

    private void initView() {
        context = this;
        iv_back=(ImageView) findViewById(R.id.regist_back);
        tv_guize=(TextView) findViewById(R.id.tv_guize);
        iv_back.setOnClickListener(this);
        tv_guize.setOnClickListener(this);
        tv_name=(TextView) findViewById(R.id.tv_name);
        tv_age=(TextView) findViewById(R.id.tv_age);
        bt_finish=(Button) findViewById(R.id.bt_finish);
        bt_finish.setOnClickListener(this);
        tv_affiliated=(TextView) findViewById(R.id.tv_affiliated);
        tv_partyDuties=(TextView) findViewById(R.id.tv_partyDuties);
        tv_admDuties=(TextView) findViewById(R.id.tv_admDuties);
        tv_joinPartyDate=(TextView) findViewById(R.id.tv_joinPartyDate);
        tv_contactNumber=(TextView) findViewById(R.id.tv_contactNumber);
        iv_headImg=(ImageView) findViewById(R.id.iv_headImg);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId())
        {
            case R.id.regist_back:
                finish();
                break;
            case R.id.tv_guize:
                break;
            case R.id.bt_finish:
                Tools.setSharedPreferencesStrings(Constant.SharePreferencePartyUserInfo,"",context);
                Intent intent=getIntent();
                setResult(1,intent);
                finish();
                break;
        }
    }

}
